package com.changjiang.luban.dao.sys;


import com.changjiang.luban.dao.domain.sys.SysUser;
import com.changjiang.luban.utils.dao.BaseDao;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 系统用户持久层接口
 * @author nichangjiang
 * @since 2017/5/29
 */
@Repository
public interface SysUserDao extends BaseDao<SysUser,Long> {

    /**
     * 通过登录名查询用户
     * @param logName
     * @return
     */
    SysUser findByUserName(String logName);

    @Query("select s from SysUser as s join fetch s.roles role where role.id=:id")
    List<SysUser> findAll(@Param("id") Long id);


    @Query("select s from SysUser as s  where s.id=:id")
    SysUser findInfo(@Param("id") Long id);
}
